04. Data Cleaning and Transformation
PRDTM2-785 AI Trading C2 L2 Vid4 Data Cleaning And Transformation
Simplifying Data Cleaning and Transformation
Data analysis can be challenging when dealing with different data formats and corrupted or missing values. Data cleaning and transformation steps are essential in the machine learning pipeline.
Data Cleaning
- Preprocessing involves changing the format and type of data, and fixing corrupted or missing data.
Data Transformation
- Casting: Changes data types, like converting strings to datetimes or integers to floats.
- Handling Strings: Numeric data may import as strings if corrupt observations include letters. All column data is treated as strings unless corrections are made.
Common Issues and Solutions
- Commas: Pandas reads numbers with commas as strings. Solve by replacing commas with empty strings and using casting methods (
intorfloat). - Missing Data: Decide to remove columns or rows based on the amount of missing data and its importance.
Effective data cleaning enhances analysis and ensures datasets are ready for further processing.
SOLUTION:
- Perform a quick visual inspection to spot any obvious issues in the data.
- Replace problematic characters (like commas or dollar signs) before converting the data type.